$(function () {
    var markid = getUrlString('markid'),page = -1,totalSize = 0;



    var mRefresh = new MiniRefresh({
        container: '#mrefresh', //这里是插件的容器ID
        down: {
            isAuto: false,
            callback: function () {
                // 下拉后的回调事件 ，你可以在这里执行你的后台请求数据函数，达到刷新数据的作用
                $('#showcaseBoxList').empty();//清空容器
                totalSize = 0;
                page = -1;
                mRefresh.endDownLoading();
            }
        }
        ,
        up: {
            isAuto: true,
            callback: function () {
                // 向上拉后的回调事件
                page += 1;
                blackList(page);
            }
        }
    });
    function blackList(page) {
        //加载动画
        getData('post','/niu/apiv3/weibo_getblackuserlist.php',{'markid':markid,'page':page},function (data) {
            console.log(data);
            if(data.resultcode == 0 ){
                var append = '';
                $(data.data).each(function () {
                    append += '<li>' +
                        '                    <img src="'+this.faceurl+'" alt="">' +
                        '                    <span>'+this.nick+'</span>' +
                        '                    <input type="hidden" value="'+this.blockuserid+'"> ' +
                        '                </li>'
                });
                $('#showcaseBoxList').append(append);

                //总条数
                totalSize = totalSize + data.pagesize;
                if (totalSize > data.datacount)
                    mRefresh.endUpLoading(true);
                else{
                    mRefresh.endUpLoading(false);
                }

                $('.showcaseBoxList li').click(function () {
                    var blockuserid = $(this).find('input').val();
                    var _this = $(this);
                    layer.confirm('请确认是否将该用户移出黑名单？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        var parameter = {
                            'set':'del',
                            'blockuserid':blockuserid,
                            'markid':markid
                        };

                        getData('post','/niu/api/weibo_doblackuser.php',parameter,function (data) {
                            console.log(data);
                            laymsg(data.msg);
                            _this.hide();
                        })
                    }, function(){

                    });
                })
            }else {
                laymsg(data.msg)
            }

        })
    }
});